<?php ob_start();
include("config/config.php"); 
///////Facebook Login //////////////
require 'facebook/facebook.php';
$facebook = new Facebook(array(
  'appId' => '363494293683738',
  'secret' => 'f9a6ca49f09ff6a5ee6fa0963fbba676',
));
$user = $facebook->getUser();

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');	
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}
//print_r($user_profile);
///Check if login with facebook
if(isset($user_profile)&&(!isset($_SESSION['id']))){
	$chk=mysql_query("SELECT * FROM `my_user` WHERE `facebook_id`='".$user_profile['id']."' ")or die(mysql_error());	
	if(!mysql_num_rows($chk)){
		$sql=mysql_query("INSERT INTO `my_user` SET `facebook_id`='".$user_profile['id']."', 
													`fname`='".$user_profile['first_name']."',
													`lname`='".$user_profile['last_name']."',													
													`dob`='".addslashes($user_profile['birthday'])."',
													`gender`='".$user_profile['gender']."' ")or die(mysql_error());
		$id=mysql_insert_id();
		if($sql){ 
			$sql2=mysql_query("SELECT * FROM `my_user` WHERE `id`=$id ")or die(mysql_error());	
			$rows=mysql_fetch_array($sql2);
			$_SESSION['id']=	$rows['id'];
			$_SESSION['fname']=	$rows['fname'];
			if(isset($_SESSION['business_url'])&&($_SESSION['business_url']!="")){
				header("location:dashboard.php"); exit;
			}else{
				header("location:http://mycitydial.com"); exit;
			}
		}
	}else{
		$sql2=mysql_query("SELECT * FROM `my_user` WHERE `facebook_id`='".$user_profile['id']."' ")or die(mysql_error());	
		$rows=mysql_fetch_array($sql2);
		$_SESSION['id']=	$rows['id'];
		$_SESSION['fname']=	$rows['fname'];
		if(isset($_SESSION['business_url'])&&($_SESSION['business_url']!="")){
			header("location:dashboard.php"); exit;
		}else{
			header("location:http://mycitydial.com"); exit;
		}
	}	
}
//////End Facebook Login///////////////
    $currentFile = $_SERVER["PHP_SELF"];
    $parts = explode('/', $currentFile);
    $page =  $parts[count($parts) - 1];
  if($page=="newpage.php"){
	  $urlid=get_item('my_business_url','url',$_REQUEST['url'],'id'); 
	  $meta=get_allitem('my_page_details','url_id',$urlid); 
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="shortcut icon" href="images/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php  if(isset($meta['page_title'])){echo substr($meta['page_title'],0,50); }else{?>Welcome to Mycitydial:- Get more Fans, Get more Leads<?php }?></title>
<meta name="description"  content="<?php if(isset($meta['description'])){echo substr(stripslashes($meta['description']),0,100); }else{?>Easy way to developer your fanpage and add more friends. get enjoy<?php }?>" />
<meta name="keyword"  content="Make fanpage, make a page on mycitydial, get more fans, get more leads" />
<link href="css/myci
tydial.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen"  />
<script type="text/javascript" src="js/html5.js"></script> 
<script type="text/javascript" src="js/jquery.js"></script> 
<script type="text/javascript" src="js/jquery.form.js" ></script> 
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="js/city.js"></script> 
<script type="text/javascript" src="js/jquery.isotope.min.js"></script>


</head>
<body>
<!--Main div start-->
<div id="main_container">
<!--Header Section start-->
<header class="header">
<div class="logo"><a href="index.php"><img src="images/logo.png" alt="mycitydial"  title="mycitydial" /></a></div>
<nav class="topnav">
<ul>
<li><iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FConnectmorepeople%2F470502979667976&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=true&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></li> 
<li><a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo site_url(); ?>" data-via="mycitydial" data-lang="en">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></li> 
</ul>
</nav>


</header>
<!--Header Section end-->

<?php 
if ($page=='what_new.php'||$page=='create_page.php'||$page=='myfan_page.php'||$page=='business_page.php' /*||$page=='create_page_step1.php' ||$page=='create_page_step2.php'   ||$page=='create_page_step3.php'  ||$page=='create_page_step4.php' || $page=='deshboard.php' */  ){
	include("nav.php"); 
}

?>